import axios from "axios";

interface IResponse<T> {
  message: string;
  result: T;
  code: number;
}

type IParams = {
  url: string;
  type: "GET" | "POST" | "get" | "post";
  data?: any;
};
function request(params: IParams): Promise<IResponse<number[]>> {
  return new Promise((resolve, reject) => {
    setTimeout(() => {
      resolve({
        code: 200,
        result: [1, 2],
        message: "获取成功",
      });
    }, 1000);
  });
}

const get = (url: string, data?: any) => {
  return axios.get(url, data);
};
const post = (url: string, data?: any) => {
  return axios.post(url, data);
};
export { request, get, post };
